package com.controller;

import com.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/studentController")
public class StudentController {
    @RequestMapping("/get")
//    public ModelAndView get(){
////        return new ModelAndView("/1","x","555");
////    }
    @ResponseBody  //有了这个注解 方法的返回值会转换成json格式的字符串
    public Student get(){
      return   new Student("张三",175);
     }

    @RequestMapping("/gets")
    @ResponseBody  //有了这个注解 方法的返回值会转换成json格式的字符串
    public List<Student> gets(){
        return Arrays.asList(new Student[]{new Student("张三",175),new Student("李四",165),new Student("网二",172)});
    }
}
